#ifndef __NET_UTILS_HPP__
#define __NET_UTILS_HPP__

#include <cstdint>
#include <string>
#include "NetConstants.h"
#include "asio.hpp"

namespace LiteNetLib
{
    typedef asio::ip::udp::endpoint net_endpoint;
}

namespace LiteNetLib::NetUtils
{
    inline int32_t RelativeSequenceNumber(int32_t number, int32_t expected)
    {
        return (number - expected + NetConstants::MaxSequence + NetConstants::HalfMaxSequence) % NetConstants::MaxSequence - NetConstants::HalfMaxSequence;
    }

    size_t SockHashCode(net_endpoint *endpoint);

    std::string GetAddressStr(net_endpoint *endpoint);

    std::string GetSockIP(net_endpoint *endpoint);


    uint64_t ByteToUInt64(const char *buff);

    int64_t ByteToInt64(const char *buff);

    uint32_t ByteToUInt32(const char *buff);

    int32_t ByteToInt32(const char *buff);

    uint16_t ByteToUInt16(const char *buff);

    int16_t ByteToInt16(const char *buff);

    void UInt64ToByte(char *buff, uint64_t value);

    void Int64ToByte(char *buff, int64_t value);

    void UInt32ToByte(char *buff, uint32_t value);

    void Int32ToByte(char *buff, int32_t value);

    void UInt16ToByte(char *buff, uint16_t value);

    void Int16ToByte(char *buff, int16_t value);

    std::string ToHexString(const void* ptr, uint32_t length);

}

#endif
